package com.xoa.service.cms.core;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * Created by cyt on 2018/7/7.
 */
public class RequestUtils {

    /**
     * 取得参数哈希表

     * @param request
     * @return
     */
    public static Map<String, String> getParamMap(HttpServletRequest request) {
        Map<String, String> rtMap = new HashMap<String, String>();
        Map<String, String[]> paramMap = request.getParameterMap();

        Iterator<String> iKeys = paramMap.keySet().iterator();
        while (iKeys.hasNext()) {
            String key = iKeys.next();
            String[] value = paramMap.get(key);
            if (value != null && value.length > 0) {
                rtMap.put(key, value[0]);
            }else {
                rtMap.put(key, "");
            }
        }

        return rtMap;
    }
}
